################
#PSRM: Explaining Support for Redistribution: Social Insurance Systems and Fairness
#
#Observational Analysis ESS
#Figure A 2
#
#Verena Fetscher
#July 2022
####################


####################
# Load data
####################
source("dataframes.R")


##########################
#Produces Figure A.2: Distribution of unemployment risk over 2-digit ISCO.
##########################


summary(data_imputed$isco2d)
ggplot(data_list,aes(x=isco2d, y=our))+
  xlim(c(0,50))+
  stat_summary_bin(aes(y = our*100), fun = "mean", 
                   geom = "bar",fill="blue")+
  stat_summary_bin(data=data_imputed,aes(y = our*100), 
                   fun = "mean", geom = "bar",
                   fill="red",alpha=.5)+
  xlab("ISCO 2-digit") +  
  ylab ("Unemployment rate (in %)")+ 
  theme_bw()+
  theme(panel.border=element_blank(),axis.line=element_line(),
        legend.position="bottom",legend.text = element_text(size = 14),
        legend.title = element_text(size=14),axis.text=element_text(size=12),
        axis.title=element_text(size=14),strip.background =element_rect(fill=F,colour = "white"))+
  facet_wrap(~factor(country))


##########################
#Save figure
##########################

ggsave(file="figure_a2.pdf", height = 5.83, width = 8.27, units = "in")

